﻿using System;
using System.Collections.Generic;
using TheSnakeGame.Engine.GameObjects;

namespace TheSnakeGame.Engine
{
    internal class WallFactory
    {
        private int width;
        private int height;

        public WallFactory(int width, int height)
        {
            if (width < 3)
            {
                throw new ArgumentOutOfRangeException("width", "width cannot be less then 3");
            }

            if (height < 3)
            {
                throw new ArgumentOutOfRangeException("height", "height cannot be less then 3");
            }

            this.width = width;
            this.height = height;
        }

        public IList<BarierObject> GetWalls()
        {
            var walls = new List<BarierObject>();
            for (int i = 1; i < this.width - 1; i++)
            {
                var buttomWallObject = new BarierObject(new Point(i, 0));
                var topWallObject = new BarierObject(new Point(i, this.height - 1));

                walls.AddRange(new BarierObject[] { buttomWallObject, topWallObject });
            }

            for (int i = 0; i < this.height; i++)
            {
                var leftWallIObject = new BarierObject(new Point(0, i));
                var rightWallObject = new BarierObject(new Point(this.width - 1, i));

                walls.AddRange(new BarierObject[] { leftWallIObject, rightWallObject });
            }

            return walls;
        }
    }
}
